<%--
  Created by IntelliJ IDEA.
  User: dh
  Date: 2019/11/25
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
        <title>供应商-物资关系列表</title>
        <%@ include file="../../common/jsp/header.jsp"%>
    <link rel="stylesheet" href="<%=path%>static/css/plugins/ztree/zTreeStyle/zTreeStyle.css">
    <script type="text/javascript" src="<%=path%>static/js/plugins/ztree/jquery.ztree.core-3.5.js"></script>
</head>
<script language="JavaScript">

    $(function () {
        var setting = {
            view: {
                dblClickExpand: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeClick: beforeClick,
                onClick: onClick
            }
        };

        $.post(root+'group/queryAllOrg.do',function (zNodes) {
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        },'json')

    })

    function beforeClick(treeId, treeNode) {
        // var check = (treeNode && !treeNode.isParent);
        // if (!check) alert("不能选择文件夹选项");
        // return check;
    }

    function onClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getSelectedNodes(),
            v = "";
        id = "";
        nodes.sort(function compare(a,b){return a.id-b.id;});
        for (var i=0, l=nodes.length; i<l; i++) {
            v += nodes[i].name + ",";
            id += nodes[i].id + ",";
        }
        if (v.length > 0 ) v = v.substring(0, v.length-1);
        if (id.length > 0 ) id = id.substring(0, id.length-1);
        var nameObj = $("#nodeName");
        nameObj.attr("value", v);
        $("#groupPid").val(id);
    }

    function showMenu() {
        var cityObj = $("#nodeName");
        var cityOffset = $("#nodeName").offset();
        $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

        $("body").bind("mousedown", onBodyDown);
    }
    function hideMenu() {
        $("#menuContent").fadeOut("fast");
        $("body").unbind("mousedown", onBodyDown);
    }
    function onBodyDown(event) {
        if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
            hideMenu();
        }
    }

</script>
<body>
${page.list}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">

    <form class="form-inline">
        <input type="hidden1" id="groupPid" name="groupPid" value=""/>
        <div class="alert alert-success" role="alert">供应商详细信息</div>
            <div class="form-group col-md-4">
                <label  for="">供应商</label>
                <input type="text" class="form-control" id="nodeName1"  name="nodeName1" placeholder="点击请选择">
                <a href="#" class="glyphicon glyphicon-search" role="button" ></a>
            </div>
            <div class="form-group col-md-4">
                <label for="">物资</label>
                <input type="text" class="form-control" id="nodeName2"  name="nodeName2" placeholder="点击请选择">
                <a href="#" class="glyphicon glyphicon-search" role="button"></a>
            </div>
            <div class="form-group col-md-4">
                <label for="">组织</label>
                <input type="text" class="form-control" id="nodeName"  name="nodeName" placeholder="点击请选择">
                <a href="#" class="glyphicon glyphicon-search" role="button" onclick="showMenu(); return false;"></a>
                <div id="menuContent" class="menuContent " style="display:none;">
                    <ul id="treeDemo" class="ztree" style="margin-top:0; width:160px;"></ul>
                </div>
            </div>
         <p>&nbsp</p>
        <div class="btn-group btn-group-justified" role="group">
            <div class="col-md-2 col-md-offset-5">
                <button type="button" class="btn btn-info" data-toggle="modal" id="query" name="relation/query.do">
                    <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>查询
                </button>
            </div>
            <div class="col-md-5">
                <button type="button" class="btn btn-info" data-toggle="modal" id="create" name="relation/create.jsp">
                    <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>新增
                </button>
            </div>
        </div>
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <table class="table table-striped table-bordered table-hover table-condensed">
        <thead>
           <tr>
               <th>组织</th>
               <th>供应商</th>
               <th>物资</th>
               <th>税率</th>
               <th>收货组织</th>
               <th>操作</th>
           </tr>
        </thead>
        <tbody>
             <c:set var="vs"></c:set>
             <c:forEach var="e" items="${page.list}" varStatus="v">
             <c:forEach var="s" items="${e.suppliers}" varStatus="vi">
             <c:forEach var="g" items="${e.gams}" varStatus="vi">
                 <tr>
                 <td class="col-md-2">${e.groups.groupName}</td>
                 <td class="col-md-2">${s.supplierName}</td>
                 <td class="col-md-2">${g.gamName}</td>
                 <td class="col-md-2"></td>
                 <td class="col-md-2">${e.supplierYangChu}</td>
                 <td class="col-md-1">
                     <button type="button" class="btn btn-link btn-xs">编辑</button>
                 </td>
                 </tr>
             </c:forEach>
             </c:forEach>
             </c:forEach>
        </tbody>
    </table>
        <div class="page">${page}</div>


    </form>
    </div>
</div>
</body>
</html>
